#pragma once

#include <lib3d/hard/VertexBuffer.h>
#include <lib3d/hard/Manager.h>
#include <HardwareDependentObject.h>
#include <math/Vector2.h>
#include "Node.h"

namespace liba
{
namespace lib3d
{
namespace node
{
			
class Plume2D : public Node, public HardwareDependentObject<hard::Manager, hard::VertexBuffer>
{
NODE_DEFINITION(Plume2D)
private:
	float                              _transparency;
	Color                              _color;
	bool                               _needUpdate;
	float                              _width;
	std::vector<math::Vector2<float> > _points;
protected:
	virtual void on_add_hardware(hard::Manager::hardware_type * ha) LIBA_OVERRIDE;
	virtual bool on_attribute(xml::Provider * provider, const std::string & name, const std::string & value) LIBA_OVERRIDE;
public:
	static const Atom node_name;
private:
	void rebuildPlume();
	math::Vector2<float> transformPoint(const lib3d::Matrix & matrix, const math::Vector2<float> & point);
public:
	Plume2D(const Atom & name, Node * parent);
	virtual ~Plume2D();
	virtual Plume2D * Clone() LIBA_OVERRIDE;
	virtual void RenderToList(hard::Hardware * hardware, hard::RenderList * render_list) LIBA_OVERRIDE;
	void add_point(const math::Vector2<float> & point);
	void clear();
	void set_width(float width);
	float get_width();
	void set_color(const Color & color);
	Color get_color();
	void set_transparency(float transparency);
	float get_transparency();
};

}
}
}
